package com.os.pojo.virtualmemory;

import com.os.content.MemoryContent;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;

/**
 * 页
 * 将进程的逻辑空间划分成若干个大小相等的部分
 */
@AllArgsConstructor
public class Page implements MemoryBlock {
    /**
     * 存在段号
     */
    public int segmentId;

    /**
     * 页号
     */
    public int id;
    /**
     * 是否已经被占用
     */
    @Getter
    public boolean isUsed;

    /**
     * 对应内存块id
     */
    public int frameId;

    /**
     * 页内偏移
     */
    public int len;

    /**
     * 表示内存内容的字符数组
     */
    public char[] chars;

    @Setter
    @Getter
    public int LRUTime;

    @Setter
    @Getter
    public int FIFOTime;


    @Setter
    public boolean CLOCKBit;

    public Page() {

    }

    public Page(int segmentId, int id, boolean isUsed, int frameId, int len, char[] chars) {
        this.segmentId = segmentId;
        this.id = id;
        this.isUsed = isUsed;
        this.frameId = frameId;
        this.chars = chars;
        this.LRUTime = 0;
        this.CLOCKBit = false;
        this.len = len;
    }

    @Override
    public int getId() {
        return id;
    }

    @Override
    public int getSize() {
        return MemoryContent.FRAME_SIZE;
    }

    @Override
    public int getParId() {
        return segmentId;
    }

    @Override
    public boolean getCLOCKBit() {
        return CLOCKBit;
    }


}
